﻿using System;

namespace DotNetCommon.Validate.Annotations;

/// <summary>
/// 字符串不能为null或空字符串或空白字符, 示例:
/// <code>
/// [VNotNullOrWhiteSpace]
/// public string Description { get; set; }
/// </code>
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public sealed class VNotNullOrWhiteSpaceAttribute : Attribute, IValidateAction
{
    public string ErrorMessage { get; set; }

    public void Action(IValidateContext ctx)
    {
        ValidateStringExtensions.MustNotNullOrWhiteSpaceInternal(ctx, ErrorMessage);
    }
}
